package at.fhj.itm;

import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class Mail extends Activity {
	public static void sendMail(Context context, String emailTo,
			String subject, String emailText, String filePath) {
		// need to "send multiple" to get more than one attachment
		final Intent emailIntent = new Intent(
				android.content.Intent.ACTION_SEND);
		emailIntent.setType("plain/text");
		emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
				new String[] { emailTo });
		// has to be an ArrayList
		ArrayList<Uri> uris = new ArrayList<Uri>();
		// convert from paths to Android friendly Parcelable Uri's
		File fileIn = new File(filePath);
		Uri u = Uri.fromFile(fileIn);
		uris.add(u);
		emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
		
		Intent i = Intent.createChooser(emailIntent, "Send mail...");
		i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(i);
	}
	
	public static void sendMMS(Context context, String mmsTo,
			String subject, String mmsText, String filePath) {
		final Intent mmsIntent = new Intent(
				android.content.Intent.ACTION_SEND);
		mmsIntent.putExtra("address", mmsTo); 
		mmsIntent.putExtra("sms_body", mmsText); 
		// has to be an ArrayList
		ArrayList<Uri> uris = new ArrayList<Uri>();
		// convert from paths to Android friendly Parcelable Uri's
		File fileIn = new File(filePath);
		Uri u = Uri.fromFile(fileIn);
		uris.add(u);
		mmsIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
		mmsIntent.setType("image/png"); 
		
		
		
		Intent i = Intent.createChooser(mmsIntent, "Send mms...");
		i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(i);
	}
}
